import { createRouter, createWebHistory } from 'vue-router'
// import HomeView from '../views/HomeView.vue'
import ProfileEdit from '@/views/ProfileEdit.vue'
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    // {
    //   path: '/',
    //   name: 'home',
    //   component: HomeView
    // },
    // {
    //   path: '/about',
    //   name: 'about',
    //   // route level code-splitting
    //   // this generates a separate chunk (About.[hash].js) for this route
    //   // which is lazy-loaded when the route is visited.
    //   component: () => import('../views/AboutView.vue') //路由懒加载
    // }
    {
      path: '/',
      redirect: '/profile'
    },
    {
      path: '/profile',
      component: ProfileEdit,
      meta: {
        title: '我的资料'
      }
    },

    {
      path: '/address',
      component: () => import('@/views/AddressManager.vue'),
      meta: {
        title: '地址列表'
      }
    },
    {
      path: '/address/edit:id?',
      component: () => import('@/views/AddressEdit.vue'),
      meta: {
        title: '地址详情'
      }
    }
  ]
})
router.afterEach((obj) => {
  document.title = obj.meta.title as string
})
export default router
